package com.yonyou.pmclouds.workstopreport.process;

import com.yonyou.pmclouds.basecom.billstatus.BillStatusConst;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.workstopreport.entity.WorkStopVO;
import com.yonyou.pmclouds.workstopreport.rmiitf.WorkStopQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WorkStopRepeatCommitProcessor implements SingleProcessor<WorkStopVO> {

    @Autowired
    private WorkStopQuery workStopQuery;

    @Override
    public void process(WorkStopVO vo, WorkStopVO orig) throws BusinessException {
        //查询当前停工的项目是否已经存在自由态，审批中，提交或者驳回的停工单。
        String pk_project = vo.getPkProject();
        int[] status = {BillStatusConst.COMMON_FREE_STATUS,BillStatusConst.COMMON_COMMIT_STATUS,BillStatusConst.COMMON_APPROVING_STATUS,BillStatusConst.COMMON_REJECT_STATUS};
        WorkStopVO[] vos = workStopQuery.queryByStatus(pk_project,status);
        if (vos != null && vos.length>0){
            throw new BusinessException("该项目已发起停工, 请不要重复发起");
        }
    }

}
